package main

import (
	"cooke-home/common/handle"
	"cooke-home/task-service/di"
	"cooke-home/task-service/route"

	"fmt"
	"log"
)

func main() {
	fmt.Println("开始初始化服务...")
	handle.InitToml()
	handle.InitApollo()
	handle.InitConsul()
	defer handle.DeregisterConsulService()
	di.InitDI()
	route.InitRouter()
	fmt.Println("服务初始化完成，开始运行...")
	StartServer()
}

func StartServer() {
	port := handle.ApolloConfigCache.GetValue("port")
	if port == "" {
		port = "8082" // 默认端口
	}
	log.Printf("服务器开始运行在端口: %s\n", port)
	route.Router.Run(":" + port)
}
